package com.icss.ah.shopVipSet.service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import org.apache.log4j.Logger;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class ShopVipInfoService {
	@Autowired
	private SqlSessionTemplate sqlSessionTemplate;

	private final Logger errlog = Logger.getLogger("E");
	private final Logger infolog = Logger.getLogger("I");
	
	public List<HashMap> queryVipCode(HashMap map) {
		List<HashMap> vipCodeMap=new ArrayList<HashMap>();
		try {
			vipCodeMap = sqlSessionTemplate.selectList("ShopVipInfoBean.queryVipCode", map);
			infolog.info("ShopVipInfoService|queryVipCode|vipCodeMap:"+vipCodeMap);
		} catch (Exception e) {
			e.printStackTrace();
			errlog.error("ShopVipInfoService|queryVipCode", e);
		} 
		return vipCodeMap;
	}
	
	
	
	public List queryVipInfoList(HashMap map) {
		
		List list = new ArrayList();
		try{
			//根据登录账号获取账号基本信息
			list = sqlSessionTemplate.selectList("ShopVipInfoBean.queryVipInfoList", map);
			infolog.info("ShopVipInfoService|queryVipInfoList|list:"+list);
			list = list == null ? new ArrayList() : list;
		} catch (Exception e) {
			e.printStackTrace();
			list = new ArrayList();
			errlog.error("ShopVipInfoService|queryVipInfoList", e);
		}
		return list;
		
	}
	
	/**
	 * 分类列表结果集统计
	 * @param map
	 * @return
	 */
	public Long getVipInfoCount(HashMap map) {
		Long reValue = 0l;
		try {
			reValue = (Long)sqlSessionTemplate.selectOne("ShopVipInfoBean.queryVipInfoCount", map);
			infolog.info("ShopVipInfoService|getVipInfoCount|reValue:"+reValue);
		} catch (Exception e) {
			e.printStackTrace();
			errlog.error("ShopVipInfoService|getVipInfoCount", e);
		} 
		return reValue;
	}

}
